package com.ruoyi.mq.controller;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JsonUtil;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.mq.producer.KafkaProducer;
import com.ruoyi.system.api.domain.SysOperLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("kafakamq")
public class KafakaController {

    @Autowired
    KafkaProducer kafkaProducer;

    @InnerAuth
    @PostMapping("/saveLog")
    public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog){
        String json = JsonUtil.objToJson(sysOperLog);
        //序列化
        kafkaProducer.sendMessage("log_queue",json);
        return null;
    }

}